//校验表单中的信息
export function getFormData(form){
    //读取表单中的数据
    var newpassword = form.newpassword.value;
    //规则校验
    //新密码不为空
    if(!newpassword){
        return {
            status: 401,
            msg: '信息填写不完全，请校验后提交'
        }
    }
    //password 为字符串 限制6位
    var passwordReg = /^(?![^a-zA-Z]+$)(?!\D+$).{3,10}$/;
    if(!passwordReg.test(newpassword)){
        return {
            status: 401,
            msg: '密码不规范'
        }
    }

    return {
        status: 200,
        data: {
            newpassword,
        }
    }
}
//选中表单
var form = document.getElementsByTagName("form")[0];
//聚焦消失后校验并给出提示
form.newpassword.onblur = function(){
    var formData = getFormData(form);
    if(formData.status == '401'){
        console.log(formData);
        form.newpassword.style.borderColor = "red";
    }else{
        form.newpassword.style.borderColor = "#ced4da";
    }
}